package top.leoseven.adminproject.modle;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CameraManager;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;

import top.leoseven.adminproject.R;

/**
 * Created by Administrator on 2018/2/11.
 */

public class ToastUtils {

    public static final int CAHAN = 1;
    public static final int SE = 2;
    public static final int JINGGAO = 3;


    public static void toast(int type, String content, Context context, int during) {
        Context context1 = context.getApplicationContext();
        View view = LayoutInflater.from(context1).inflate(R.layout.toast_layout, null, false);
        ImageView icon = (ImageView) view.findViewById(R.id.image_icon);


        TextView text= (TextView) view.findViewById(R.id.image_content);
        text.setText(content);
        switch (type) {
            case CAHAN:
                Glide.with(context1).load(R.drawable.toast_cahan).into(icon);
                break;
            case SE:
                Glide.with(context1).load(R.drawable.toast_se).into(icon);
                break;
            case JINGGAO:
                Glide.with(context1).load(R.drawable.toast_jg).into(icon);
                text.setTextColor(context1.getResources().getColor(R.color.red));
                break;
        }
        Toast toast=new Toast(context1);
        toast.setView(view);
        toast.setDuration(during);
        toast.show();
    }
}
